$(function() {
	var organDataTags = $("#organData").val().split(",");
	$(".organ").autocomplete({
		source: organDataTags
    });
})

function submitPage(obj) {
	if(UTIL.checkButton(obj)) {
		var ids = "";
		$(".data_id").each(function() {
			ids += $(this).val() + ",";
		});
		ids = ids.substring(0, ids.length-1);
		
		var param = { "ids": ids }
		API.elementDesignateOrganSubmitPage(param, function(res) {
			if(res.code == 0) {
				window.location.reload();
			} else {
				alert(res.desc);
				UTIL.releaseButton(obj);
			}
		});
	}
}

function refresh(obj) {
	if(UTIL.checkButton(obj)) {
		window.location.href="/vocab/element_designate_organ_init.htm";
	}
}

function organDesignate(obj, id) {
	var _obj = $(obj);
	var organ = _obj.val();

	var param = {
		"id": id,
		"organ": organ
	}

	API.elementDesignateOrgan(param, function(res) {
		if(res.code == 0) {
			
		} else {
			_obj.val("");
			alert(res.desc);
		}
	});
}

function parentExport(obj) {
	if(UTIL.checkButton(obj)) {
		window.location.href="/vocab/element_designate_organ_export.htm";
		UTIL.releaseButton(obj);
	}
}